import { request } from "@yaf/request";
// import { toApi } from "@/service/proxyApi";
import { RequestDataType, RespDataType } from "./apiType";
export * from "./apiType";

const { mockRespData } = request;

/**
 * 获取数据集分页列表
 */
export const getDataSetPageList = (params: { page: number, pageSize: number }) => {
  // return get<RespDataType.DataSetPageList>(toApi("project/list"), params);
  console.log("params->", params);
  return mockRespData<RespDataType.DataSetPageList>({
    total: 10,
    list: new Array(10).fill(0).map((_, index) => ({
      id: index.toString(),
      name: "test-" + (index + 1),
      createBy: "test",
      updateBy: "",
      createTime: "2022-04-11 11:11:11",
      updateTime: "2022-04-11 11:11:11",
    }))
  });
}

/**
 * 创建数据集
 */
export const createDataSet = (params: RequestDataType.CreateDataSetItem) => {
  // return postJSON(toApi("project"), params);
  console.log("params->", params);
  return mockRespData("");
}

/**
 * 获取数据集信息
 */
export const getDataSetInfo = (dataSetId: number) => {
  // return get<RespDataType.DataSetItem>(toApi("project"), {dataSetId});
  console.log("dataSetId->", dataSetId)
  return mockRespData<RespDataType.DataSetItem>({
    id: "1",
    name: "test-1",
    createBy: "test",
    updateBy: "",
    createTime: "2022-04-11 11:11:11",
    updateTime: "2022-04-11 11:11:11",
  });
}

/**
 * 更新数据集信息
 */
export const updateDataSet = (dataSetId: number, params: Partial<RequestDataType.UpdateDataSetItem>) => {
  // return put(toApi(`project?dataSetId=${dataSetId}`), params);
  console.log("dataSetId->", dataSetId)
  console.log("params->", params)
  return mockRespData("");
}

/**
 * 删除数据集信息
 */
export const deleteDataSet = (dataSetIds: number[]) => {
  // return del(toApi(`project`), {ids: dataSetIds});
  console.log("dataSetIds->", dataSetIds)
  return mockRespData("");
}

